//package com.haoze.nurseapp.schedule;
//
//import com.haoze.common.model.TaskExecuteBatchEntity;
//import com.haoze.nurseapp.dao.*;
//import com.haoze.nurseapp.enumeration.WorkSpaceEnum;
//import com.haoze.common.model.OrdersFileIndexDataEntity;
//import com.haoze.nurseapp.model.StaticCenterEntity;
//import com.haoze.nurseapp.service.NursePatientOrderService;
//import com.haoze.nurseapp.service.feign.PatientOrderService;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.annotation.Resource;
//import java.util.*;
//
//@Component
//@ConditionalOnProperty(prefix = "schedule", name = "createnode", havingValue = "true")
//public class CreateNextNodeSchedule {
//
//    @Resource
//    TaskExecuteDetailMapper taskExecuteDetailMapper;
//
//    @Resource
//    TaskExecuteMapper taskExecuteMapper;
//
//    @Resource
//    OrdersFileIndexDataMapper ordersFileIndexDataMapper;
//
//    @Resource
//    NursePatientOrderService patientOrderService;
//
//    @Resource
//    StaticCenterMapper staticCenterMapper;
//
//    /**
//     * 每分钟检测明细表中有qrCode及barCode且状态为0节点为静态中心的数据并为其创建下一节点
//     */
//    @Scheduled(fixedDelay = 1000*60)
////    @Scheduled(initialDelay = 1000, fixedRate = 5000000)
//    @Transactional(rollbackFor = Exception.class)
//    public void createNextNode(){
//        System.out.println("CreateNextNodeSchedule did at "+new Date().getTime());
//        String status = "";
//        String dataCode = "";
//        //String userId = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getHeader("zuul_id");
//        //String userId = "bf533ba10ec64ab0bbf360c44fa7a787";
//        List<TaskExecuteBatchEntity> taskExecuteDetailEntityList = taskExecuteDetailMapper.queryNoNextNode(WorkSpaceEnum.STATIC_DRUG_CENTER.getNodeId());
//        List<Map<String,Object>> list = new ArrayList<>();
//        for (int i = 0; i < taskExecuteDetailEntityList.size(); i++) {
//            Map<String,Object> map = new HashMap<>();
//            StaticCenterEntity staticCenterEntity = staticCenterMapper.queryPersonIdByBarCode(taskExecuteDetailEntityList.get(i).getBarCode(), "0");
//            if("1".equalsIgnoreCase(staticCenterEntity.getBatch())){
//                status = "已加药";
//                dataCode = "61224789ffe9413fb84c981f14ec13ad";
//            }else{
//                status = "未加药";
//                dataCode = "e08165457f3442beaf5a5674daabf6f3";
//            }
//            OrdersFileIndexDataEntity fileIndexDataEntity = taskExecuteMapper.queryFileIndexData(taskExecuteDetailEntityList.get(i).getTaskBatchId());
//            fileIndexDataEntity.setDataValue(status);
//            fileIndexDataEntity.setDataCode(dataCode);
//            ordersFileIndexDataMapper.updateByPrimaryKeySelective(fileIndexDataEntity);
//            map.put("taskExecuteDetailEntity",taskExecuteDetailEntityList.get(i));
//            map.put("userId","040903c762b0498e91c970030cbfa9ff");
//            list.add(map);
//        }
//        if(list.size()>0){
//            patientOrderService.createNextTaskNodeList(list,"");
//        }else{
//            return;
//        }
//    }
//}
